import path from "path"

import index from "../views/index.vue"
import login from "../views/login.vue"
import page404 from "../views/404.vue"


/**
 * 配置可导出的路由文件。
 * 根据路由导入后台服务，创建的菜单会使用enable，和menuType
 * menuUneId与menuUneIdConfirm必须一致，且不可修改
 */
var configRouterData = []
var exportRouterData = []
const propArray = ["menuUneId","menuUneIdConfirm","path","component","menuType","enable","permissions","children"]
configRouterData = [
    {
        menuUneId:"index_page_id",
        menuUneIdConfirm:"index_page_id",
        path:"/index",
        component:index,
        menuType: 2,
        enable: 1,
        permissions: "index:index",
        children:[]
    },
    {
        menuUneId:"login_page_id",
        menuUneIdConfirm:"login_page_id",
        path:"/login",
        component:login,
        menuType: 2,
        enable: 1,
        permissions: "login:login"
    },
    {
        menuUneId:"page404_page_id",
        menuUneIdConfirm:"page404_page_id",
        path:"/page404",
        component:login,
        menuType: 2,
        enable: 1,
        permissions: "page404:page404"
    },
]


function checkRouterProp(item,key){
    for(const item in propArray){
        if(item === key && item[key] != undefined){
            return true;
        }
    }
    return false;
}


function transferArray(arr){
//路由配置检查
for(const item in arr){
    for(const key in item){
        if(checkRouterProp(item,key)){
            
        }else{
            console.error("路由配置属性丢失：")
            console.dir(item)
        }
    }
}

//路由转化
for(const item in arr){
    var tmpArr = [];
    if(item.children.length > 0){
        tmpArr = transferArray(item.children)
    }

    var routerTmp = {
        path: item.path,
        component: item.component,
        children: tmpArr
    }

    exportRouterData.push(routerTmp)
}
}

debugger


export default exportRouterData